package com.shundr.shipper.truck;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.shundr.shipper.R;
import com.shundr.shipper.base.BaseFragment;
import com.shundr.shipper.common.view.CListView;
import com.shundr.shipper.truck.adapter.UserTruckTimeAdapter;
import com.shundr.shipper.truck.model.UserTrackInfo;

/**
 * 
 * UserTruckTimeFragment
 * 
 * @author larry 2015-6-27 下午2:14:03 
 * @version 1.0.0
 *
 */
public class UserTruckTimeFragment extends BaseFragment implements OnClickListener{

	private CListView mListView;
	private UserTruckTimeAdapter mAdapter;

	protected RelativeLayout mLayoutNoContent;
	protected TextView tvNoContent;

	private List<UserTrackInfo> mList = new ArrayList<UserTrackInfo>();

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_user_truck_map, null);
		initView(view);
		return view;
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {//
		super.onActivityCreated(savedInstanceState);
	}

	public void initView(View view) {
		mListView = (CListView) view.findViewById(R.id.lv_list);
		mAdapter = new UserTruckTimeAdapter(getActivity(),mList);
		mListView.setAdapter(mAdapter);
		mListView.setCanLoadMore(false);
		mListView.setAutoLoadMore(false);
		mListView.setCanRefresh(false);

		mLayoutNoContent = (RelativeLayout) view.findViewById(R.id.layout_no_content);
		tvNoContent = (TextView) view.findViewById(R.id.tv_no_content);
	}
	
	/**
	 * 
	 * refreshShaftData(这里用一句话描述这个方法的作用)
	 * (这里描述这个方法适用条件 – 可选)
	 * @param infos
	 * void
	 * @exception
	 * @since  1.0.0
	 */
	public void refreshTimeData(List<UserTrackInfo> infos){
		mList.clear();
		if(infos.size() > 0){
			mListView.setVisibility(View.VISIBLE);
			mLayoutNoContent.setVisibility(View.GONE);
			mList.addAll(infos);
			mAdapter.notifyDataSetChanged();
		}else{
			mListView.setVisibility(View.GONE);
			mLayoutNoContent.setVisibility(View.VISIBLE);
		}
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

	@Override
	public void onPause() {
		super.onPause();
	}

	@Override
	public void onResume() {
		super.onResume();
	}

	@Override
	public void onClick(View v) {
	}
}
